package com.lid.test.ws.client;

import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;

public class wsClient {
    public static void main(String[] args) throws Exception {
        JaxWsDynamicClientFactory dcf =JaxWsDynamicClientFactory.newInstance();
        //地址写成zull代理的服务器 可以正常访问到，zull可以正常代理webservice
        //org.apache.cxf.endpoint.Client client =dcf.createClient("http://localhost:8062/api/test/user?wsdl");
        org.apache.cxf.endpoint.Client client =dcf.createClient("http://localhost:8089/test/user?wsdl");
        //org.apache.cxf.endpoint.Client client =dcf.createClient("http://localhost:8080/test/user?wsdl");
//        Object[] objects=client.invoke("getUserInfo","411001","0000000");
        //设置超时单位为毫秒
        HTTPConduit http = (HTTPConduit) client.getConduit();
        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        httpClientPolicy.setConnectionTimeout(3000);  //连接超时
        httpClientPolicy.setAllowChunking(false);    //取消块编码
        httpClientPolicy.setReceiveTimeout(3000);     //响应超时
        http.setClient(httpClientPolicy);
        Object[] objects=client.invoke("getUsername","411001");
        //输出调用结果
        System.out.println("*****"+objects[0].toString());
    }
}
